package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.user.EmailNotMatchException;
import com.ruoyi.common.exception.user.UserException;
import com.ruoyi.common.exception.user.UserNotExistsException;
import com.ruoyi.framework.web.service.SysUpdatePasswordService;
import com.ruoyi.system.domain.SysUpdatePassword;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.util.RandomVerifyCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * 修改密码
 */
@RestController
public class SysUpdatePasswordController {


    @Autowired
    private SysUpdatePasswordService updatePasswordService;

    /**
     * 验证邮箱是否正确并发送验证码
     * @param updatePassword
     * @return
     */
    @PostMapping("/checkEmail")
    public AjaxResult checkEmailExist(@RequestBody SysUpdatePassword updatePassword){

        return updatePasswordService.checkEmail(updatePassword);

    }

    /**
     * 修改用户密码
     * @param updatePassword
     * @return
     */
    @PostMapping("/updatePwd")
    public AjaxResult updatePwd(@RequestBody SysUpdatePassword updatePassword){
        return updatePasswordService.updatePwd(updatePassword);
    }
}
